#ifndef _HTTPSTREAMFACTORY_HPP_
#define _HTTPSTREAMFACTORY_HPP_

#include "jhdefs.hpp"
#include "net/HTTPSession.hpp"
#include "net/URIStreamFactory.hpp"
#include <string>
#include <istream>

NET_NAMESPACE_BEGIN

class CHTTPStreamFactory : public CURIStreamFactory
{
public:
	CHTTPStreamFactory();
	CHTTPStreamFactory(const std::string& proxyHost, UInt16 proxyPort = CHTTPSession::HTTP_PORT);
	CHTTPStreamFactory(const std::string& proxyHost, UInt16 proxyPort, const std::string& proxyUsername, const std::string& proxyPassword);
	virtual ~CHTTPStreamFactory();

	virtual std::istream* open(const CURI& uri);

	static void registerFactory();
	static void unregisterFactory();

private:
	enum
	{
		MAX_REDIRECTS = 10
	};

	std::string m_proxyHost;
	UInt16		m_proxyPort;
	std::string m_proxyUsername;
	std::string m_proxyPassword;
};


NET_NAMESPACE_END

#endif
